home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / BORL_TIP / TI2000 / TI2002.ASC < prev    next >
Text File  |  1993-04-19  |  3KB  |  133 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Pascal                                NUMBER  :  2002
  9.   VERSION  :  7.0
  10.        OS  :  DOS
  11.      DATE  :  April 19, 1993                           PAGE  :  1/1
  12.  
  13.     TITLE  :  Readjusting HeapLimit and HeapBlock
  14.  
  15.  
  16.  
  17.  
  18.   Program that demonstrates the allocation of different blocks
  19.   sizes and HeapLimit and HeapBlock in protected mode.^@
  20.  
  21.      1.  program testmem;
  22.  
  23.      2.  { If you try to allocate blocks of memory greater than 1k,
  24.          you can }
  25.          { run out of memory handles before you run out of memory.
  26.          This    }
  27.          { has to do with the number of memory handles you can have
  28.          under   }
  29.          { protected mode, your blocks are larger than the amount
  30.          the       }
  31.          { suballocator is set to (1k), you can change this by
  32.          changing     }
  33.          { HeapLimit and HeapBlock (see below). HeapLimit should be
  34.          2 to 6  }
  35.          { times the size of your block.  HeapBlock should be 4+
  36.          times the  }
  37.          { size of HeapLimit. HeapLimit should not grow over 16k
  38.          and the    }
  39.          { max value of HeapBlock is 64k.
  40.          }
  41.  
  42.      3.  uses crt;
  43.  
  44.      4.  const
  45.          MaxSize = 2048;        { your block size }
  46.  
  47.      5.  type
  48.          Trec = array[0..MaxSize] of byte;
  49.  
  50.      6.  var
  51.          Rec : ^Trec;
  52.          Total,
  53.          l : longint;
  54.  
  55.      7.  begin
  56.          { Change the heap block size the suballocator uses if the
  57.          block }
  58.          { size is larger than than HeapLimit.
  59.          }
  60.          if HeapLimit < MaxSize then begin
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Pascal                                NUMBER  :  2002
  75.   VERSION  :  7.0
  76.        OS  :  DOS
  77.      DATE  :  April 19, 1993                           PAGE  :  2/1
  78.  
  79.     TITLE  :  Readjusting HeapLimit and HeapBlock
  80.  
  81.  
  82.  
  83.  
  84.          HeapLimit := MaxSize*2;
  85.          HeapBlock := HeapLimit*4;
  86.          end;
  87.  
  88.          clrscr;
  89.          Total := 0;
  90.          Writeln('maxavail at start of program = ', maxavail);
  91.  
  92.          l := 0;
  93.          repeat
  94.          gotoxy(1,2);
  95.          writeln(l, '    maxavail = ', maxavail:10, '         ');
  96.          WriteLn('MemAvail: ', MemAvail:10, '        ');
  97.          inc(l);
  98.          New(Rec);
  99.          Total := Total + MaxSize;
  100.          GotoXY(1,4);
  101.          WriteLn('Total: ', Total);
  102.          until false;
  103.          readln;
  104.          end.
  105.  
  106.   DISCLAIMER: You have the right to use this technical information
  107.   subject to the terms of the No-Nonsense License Statement that
  108.   you received with the Borland product to which this information
  109.   pertains.
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.